#pragma once
#include <string>
#include <iostream>

using namespace std;

struct Material
{
	std::wstring albedo;
	std::wstring normal;
};

inline void serialize_material(Material& mat, ostream& out)
{
	int count = mat.albedo.size();
	out.write((char*)&count, sizeof(decltype(count)));
	out.write((char*)mat.albedo.c_str(), count * sizeof(wchar_t));
	count = mat.normal.size();
	out.write((char*)&count, sizeof(decltype(count)));
	out.write((char*)mat.normal.c_str(), count * sizeof(wchar_t));
}
inline Material deserialize_material(istream& in)
{
	Material mat;
	int count;
	in.read((char*)&count, sizeof(decltype(count)));
	wchar_t* path = new wchar_t[count];
	in.read((char*)path, count * sizeof(wchar_t));
	mat.albedo = wstring(path, count);

	in.read((char*)&count, sizeof(decltype(count)));
	path = new wchar_t[count];
	in.read((char*)path, count * sizeof(wchar_t));
	mat.normal = wstring(path, count);
	delete [] path;
	return mat;	
}
